package com.yxym.Throws_;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class Throws02 {
    public static void main(String[] args) {
        So so = new So();
        so.method();
    }
    public static void f1() throws FileNotFoundException{
        f2();//f2方法抛出编译异常，f1需要处理这个编译异常，可以使用try catch 或者throws处理
    }
    public static void f2() throws FileNotFoundException {
        FileInputStream fileInputStream = new FileInputStream("d://aa.txt");
    }
    public void f3(){
        f4();//f4抛出运行异常，f3可以不处理。系统默认throws处理机制
    }
    public void f4() throws ArithmeticException{
    }
}
class Fa{
    public void method() throws RuntimeException{
        System.out.println("method方法调用...");
    }
}
class So extends  Fa {
    //子类抛出异常与父类类型相同，或者为父类类型的子类
    @Override
    public void method() throws RuntimeException {
        super.method();
    }
}